Skip to content

fix: prevent 500 on contributor identity update by filtering non-updatable fields#4077

Merged
joanagmaia merged 4 commits intomainfrom
fix/ui-identities-update
May 7, 2026
Merged

fix: prevent 500 on contributor identity update by filtering non-updatable fields#4077
joanagmaia merged 4 commits intomainfrom
fix/ui-identities-update

Conversation

@joanagmaia
Copy link
Copy Markdown
Contributor

@joanagmaia joanagmaia commented May 6, 2026

Issue

Updating a contributor identity from the UI returned a 500 from the backend.

The frontend was spreading the full identity object into the PATCH payload, so fields that aren't updatable (e.g. createdAt, memberId, id) were sent to the API. The backend's updateMemberIdentity then built a SQL UPDATE from every key it received, which produced an invalid statement and crashed the request.

Fix

Frontend — only send fields the API is meant to accept.

  • Introduced UpdateContributorIdentityPayload type with the updatable fields only (value, type, platform, verified, source, sourceId, integrationId).
  • contributor-identity-edit.vue now picks value and type explicitly instead of spreading form.
  • ContributorIdentitiesApiService.update and the updateContributorIdentity store action are typed against the new payload.

Backend — defense-in-depth so an unexpected field can't break the query again.

  • updateMemberIdentity (services/libs/data-access-layer/src/members/identities.ts) now filters the incoming data against an allowlist (UPDATABLE_IDENTITY_FIELDS: platform, value, type, verified, verifiedBy, source, sourceId, integrationId) and drops undefined values before building the SET clause.

Note

Medium Risk
Touches contributor identity update flow end-to-end (UI payload, API client, and SQL update builder); mistakes could prevent legitimate identity updates or silently drop fields.

Overview
Prevents contributor identity updates from triggering backend 500s by sending only allowed fields from the UI and tightening types via a new UpdateContributorIdentityPayload used by the store action and ContributorIdentitiesApiService.update.

Adds defense-in-depth in updateMemberIdentity by allowlisting updatable columns and dropping undefined values before building the SQL SET clause, avoiding invalid updates when unexpected fields are provided.

Reviewed by Cursor Bugbot for commit 0df4b73. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings May 6, 2026 11:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

2 similar comments
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a backend 500 when updating contributor/member identities by preventing non-updatable fields from reaching the SQL UPDATE builder, adding backend allowlisting as defense-in-depth.

Changes:

  • Backend: updateMemberIdentity now filters incoming update fields against an allowlist and drops undefined values before generating the SET clause.
  • Frontend: introduces UpdateContributorIdentityPayload and updates identity edit flow/API typings to send only intended updatable fields.
  • Frontend: identity edit form now explicitly constructs the PATCH payload instead of spreading the full identity object.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
services/libs/data-access-layer/src/members/identities.ts Filters update payload keys to prevent invalid SQL updates from unexpected fields.
frontend/src/modules/contributor/types/Contributor.ts Adds a dedicated update payload type with only updatable identity fields.
frontend/src/modules/contributor/store/contributor.actions.ts Tightens typing for the identity update action to the new payload type.
frontend/src/modules/contributor/services/contributor.identities.api.service.ts Updates PATCH method signature/body to use the new payload type.
frontend/src/modules/contributor/components/edit/identity/contributor-identity-edit.vue Sends a curated subset of fields instead of spreading the full form object.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@joanagmaia joanagmaia force-pushed the fix/ui-identities-update branch from 4d7b352 to a2e1939 Compare May 6, 2026 11:54
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@joanagmaia joanagmaia force-pushed the fix/ui-identities-update branch from a2e1939 to f8890c8 Compare May 6, 2026 11:55
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@joanagmaia joanagmaia requested review from skwowet May 6, 2026 12:06
Copilot AI review requested due to automatic review settings May 7, 2026 10:07
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment on lines +35 to 43
static async update(memberId: string, id: string, payload: UpdateContributorIdentityPayload) {
return authAxios.patch(
`/member/${memberId}/identity/${id}`,
payload,
{
...identity,
segments: getSegments(),
params: {
segments: getSegments(),
},
},
Comment on lines +133 to +136
const filtered = Object.fromEntries(
Object.entries(data).filter(
([k, v]) => (UPDATABLE_IDENTITY_FIELDS as readonly string[]).includes(k) && v !== undefined,
),
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

⚠️ Jira Issue Key Missing

Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability.

Example:

  • feat: add user authentication (CM-123)
  • feat: add user authentication (IN-123)

Projects:

  • CM: Community Data Platform
  • IN: Insights

Please add a Jira issue key to your PR title.

@joanagmaia joanagmaia merged commit 8279254 into main May 7, 2026
16 checks passed
@joanagmaia joanagmaia deleted the fix/ui-identities-update branch May 7, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants